package com.maijinjie.common.util;

import javax.servlet.http.HttpServletRequest;

/**
 * 页面请求辅助工具类
 * @version 1.0
 * @author GhostarX ( 王欣逸 ) 100992995@qq.com &copy;广州迈今捷信息科技有限公司
 */
public class RequestUtil {
	/**
	 * 获取IP地址
	 * @param req
	 * @return String IP地址
	 */
	public static String getIP(HttpServletRequest req) {
		String ip = req.getHeader("x-forwarded-for");
		if (ip == null || ip.length() == 0) {
			if ("unknown".equalsIgnoreCase(ip)) {
				ip = req.getHeader("Proxy-Client-IP");
			}
			if ("unknown".equalsIgnoreCase(ip)) {
				ip = req.getHeader("WL-Proxy-Client-IP");
			}
			if ("unknown".equalsIgnoreCase(ip)) {
				ip = req.getRemoteAddr();
			}
		}
		return ip;
	}
	
}
